package com.zhengdongzulin.zuke.app.main.mine

import androidx.lifecycle.rxLifeScope
import com.lxj.androidktx.livedata.StateLiveData
import com.zhengdongzulin.zuke.app.Api
import com.zhengdongzulin.zuke.base.BaseViewModel
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class IdAuthVm : BaseViewModel() {

    var verify_id_card: StateLiveData<String> = StateLiveData()

    fun verify_id_card(name: String, idCard: String) {
        rxLifeScope.launch(
            {
                var r = RxHttp.postJson(Api.VERIFY_ID_CARD)
                    .add("name", name)
                    .add("idCard", idCard)
                    .toResponse<String>()
                    .await()
                verify_id_card.postValueAndSuccess(r)
            }, {
                assignment(it, verify_id_card)
            }
        )
    }

}